package Util;
import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import Model.SanPham;
public class SanPhamDataModel extends ListDataModel<SanPham> implements SelectableDataModel<SanPham>,Serializable {

	public SanPhamDataModel() {  
    }  
  
    public SanPhamDataModel(List<SanPham> data) {  
        super(data);  
    }  
	
	@Override
	public SanPham getRowData(String rowKey) {
		List<SanPham> sanphams = (List<SanPham>) getWrappedData();  
        
        for(SanPham sanpham : sanphams) {  
            if(sanpham.getTen().equals(rowKey))  
                return sanpham;  
        }  
 
        return null; 
	}

	@Override
	public Object getRowKey(SanPham sanpham) {
		
		return sanpham.getTen();
	}

	
  
    
}
